<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>16_Promise-Promise的面试题练习</title>
  </head>

  <body>
    <script>
      setTimeout(() => {
        console.log("setTimout1");

        new Promise(function (resolve) {
          resolve();
        }).then(function () {
          new Promise(function (resolve) {
            resolve();
          }).then(function () {
            console.log("then4");
          });
          console.log("then2");
        });
      });

      new Promise(function (resolve) {
        console.log("promise1");
        resolve();
      }).then(function () {
        console.log("then1");
      });

      setTimeout(() => {
        console.log("setTimout2");
      });

      console.log(2);

      queueMicrotask(() => {
        console.log("queueMicrotask1");
      });

      new Promise(function () {
        console.log("then3");
      });
    </script>

    <!-- 
  promise1
  2
  then3

  then1
  queueMicrotask1

  setTimout1
  then2
  then4

  setTimout2

  --></body>
</html>
